package ink.metoo.gude.config.jpa

import ink.metoo.gude.GudeServerApplication
import org.springframework.boot.autoconfigure.domain.EntityScan
import org.springframework.context.annotation.ComponentScan
import org.springframework.context.annotation.Configuration
import org.springframework.context.annotation.FilterType
import org.springframework.data.jpa.repository.config.EnableJpaAuditing
import org.springframework.data.jpa.repository.config.EnableJpaRepositories
import org.springframework.stereotype.Repository

@Configuration
@EntityScan(
    basePackages = [JpaConfig.MODULE_BASE_PACKAGE]
)
@EnableJpaRepositories(
    basePackages = [JpaConfig.MODULE_BASE_PACKAGE],
    includeFilters = [
        ComponentScan.Filter(
            type = FilterType.ANNOTATION,
            classes = [Repository::class]
        )
    ]
)
@EnableJpaAuditing
class JpaConfig {

    companion object {
        const val MODULE_BASE_PACKAGE = "${GudeServerApplication.BASE_PACKAGE}.module"
    }

}